using UnityEngine;

public class PanelProffileName : MonoBehaviour
{
	public static PanelProffileName instance;

	public UIInput input;

	public UILabel playerName;

	private void Awake()
	{
		instance = this;
		playerName.text = settings.tekName;
		input.value = settings.tekName;
	}

	public void SaveNameProfile()
	{
		input.value = settings.RemoveBbcode(input.value);
		playerName.text = settings.RemoveBbcode(playerName.text);
		PhotonNetwork.player.UpdateProperty(PlayerPropsKeys.nickname, playerName.text);
		if (!(playerName.text != settings.tekName))
		{
			return;
		}
		if (playerName.text != "player" && playerName.text != "Player" && playerName.text[0].ToString() != " " && playerName.text != string.Empty)
		{
			settings.setNewName(playerName.text);
			if (string.IsNullOrEmpty(settings.idPlayer))
			{
			}
		}
		else
		{
			playerName.text = BCWStorage.Get<string>(settings.keyRandomNickName);
			input.value = playerName.text;
			settings.setNewName(playerName.text);
			settings.tekName = playerName.text;
			PhotonNetwork.player.UpdateProperty(PlayerPropsKeys.nickname, playerName.text);
		}
	}
}
